/***************************************************************
*  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
*  All rights reserved.
*
*  This file is part of the GroupMe! Project. Source code of 
*  this project is closed and redistribution of this code is
*  prohibited. 
*  
*  Contact: http://www.groupme.net
*
*  This copyright notice MUST APPEAR in all copies of the file!
***************************************************************/
package net.groupme.gui.rendering;

import net.groupme.model.Resource;
import net.groupme.model.ResourceVisualization;

/**
 * created on 08.07.2007
 * 
 * This {@link Renderer} implementation renders videos.
 * 
 * @author Mischa Frank, <a href="mailto:mail@planetfrank.net">mail@planetfrank.net</a>
 * @author last edited by: $Author: mischa $
 * 
 * @version $Revision: 1.4 $ $Date: 2008-02-28 12:40:13 $
 */
public class VideoRenderer extends AbstractRenderer {

	/* (non-Javadoc)
	 * @see net.groupme.gui.rendering.AbstractRenderer#renderAsHTML(net.groupme.model.ResourceVisualization, java.lang.Integer, java.lang.Integer)
	 */
	@Override
	public String renderAsHTML(ResourceVisualization resourceVisualization,
			Integer groupWidth, Integer groupHeight, Integer zAxis) {
		String html = "";
		Resource resource = resourceVisualization.getResource();
		String width = "width:100px;";
		String height = "height:100px;";
		String widthMove = "width:100px;";
		if(resourceVisualization.getWidth() > 0){
			width = " width:" + (((resourceVisualization.getWidth()*groupWidth)/1000)-4) + "px;";
			widthMove = " width:" + (((resourceVisualization.getWidth()*groupWidth)/1000)) + "px;";
		}
		if(resourceVisualization.getHeight() > 0){
			height = " height:" + (((resourceVisualization.getHeight()*groupHeight)/1000)-55) + "px;";
		}
		
		String srcURL = resource.getURL().toString();
		//div initialisierung
		html += this.getDivAttributes(resourceVisualization, groupWidth, groupHeight, zAxis);
		//menu:
		html += this.getMenu(resourceVisualization, resourceVisualization.getURI().toString(), groupWidth);
		
		//video
		html += "<strong>" + resource.getName() + "</strong>" + "<br/>";
		html += "<object id=\"" + resourceVisualization.getURI().toString() + "_contentVideo\" style=\""+ width + height + " min-width:150px;\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" " +
				"codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" " +
				"standby=\"Loading Microsoft Windows Media Player components...\" >";
		html += "<param name=\"URL\" value=\"" + srcURL + "\">";
		html += "<param name=\"SendPlayStateChangeEvents\" value=\"True\">";
		html += "<param name=\"AutoStart\" value=\"false\">";
		html += "<param name=\"stretchToFit\" value=\"true\">";
		html += "<param name=\"uiMode\" value=\"full\">";
		html += "<param name=\"PlayCount\" value=\"1\">";
		html += "<param name=\"AutoRewind\" value=\"0\">";
		html += "<param name=\"AutoSize\" value=\"0\">";
		html += "<embed id=\"" + resourceVisualization.getURI().toString() + "_contentVideo\" type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" " +
					"name=\"mediaplayer1\" transparentstart=\"1\" style=\""+ width + height + "\"" +
					"showstatusbar=\"1\" loop=\"0\" controller=\"true\" src=\"" + srcURL + "\" stretchToFit=\"true\" AutoSize=\"0\" Autostart=\"false\"></embed>";
		html += "</object>";
		// div open _tags
		html += "<div id=\"" + resourceVisualization.getURI().toString() + "_tags\" class=\"tag\" style=\"display:none;\">";
		// close div _tags
		html += "</div>";
		//close div URI
		html += "</div>";
		html += this.getMoveBar(resourceVisualization, widthMove);
		//close div _border
		html += "</div>";
		return html;
	}

}
